//2009/07/27 12:06:15
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class Pricing
{
public:
    int maxSales(vector <int> price)
    {
        sort(price.begin(), price.end());
        int N = price.size();
        int score = 0;
        for (int i=0; i<N ;i++)
        {
            for (int j=i; j<N; j++)
            {
                for (int k=j; k<N; k++)
                {
                    for (int m=k; m<N; m++)
                    {
                        int res = 0;
                        for (int n=0; n<N; n++)
                        {
                            if (price[n]>=price[m])
                            {
                                res+=price[m];
                            }
                            else if (price[n]>=price[k])
                            {
                                res+=price[k];
                            }
                            else if (price[n]>=price[j])
                            {
                                res+=price[j];
                            }
                            else if (price[n]>=price[i])
                            {
                                res+=price[i];
                            }

                        }
						score = max(score, res);
                    }
                }
            }
        }
		return score;
    }
};
//Brute force & anumerate.
